package com.my.zl.console.controller.autocode;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.my.zl.common.dto.ReqDTO;
import com.my.zl.common.dto.ResDTO;
import com.my.zl.common.dto.advancedQuery.PageQueryDTO;
import com.my.zl.console.common.aop.LogAnnotation;
import com.my.zl.console.controller.base.BaseController;
import com.my.zl.console.entity.autocode.ZlWebComponent;
import com.my.zl.console.dto.autocode.webComponent.ReqWebComponentAddDTO;
import com.my.zl.console.dto.autocode.webComponent.ReqWebComponentDelDTO;
import com.my.zl.console.dto.autocode.webComponent.ReqWebComponentEditDTO;
import com.my.zl.console.dto.autocode.webComponent.ReqWebComponentQueryDTO;
import com.my.zl.console.dto.autocode.webComponent.ReqWebComponentDetailDTO;
import com.my.zl.console.dto.autocode.webComponent.ReqWebComponentStateDTO;
import com.my.zl.console.dto.autocode.webComponent.ResWebComponentAddDTO;
import com.my.zl.console.dto.autocode.webComponent.ResWebComponentDelDTO;
import com.my.zl.console.dto.autocode.webComponent.ResWebComponentEditDTO;
import com.my.zl.console.dto.autocode.webComponent.ResWebComponentQueryDTO;
import com.my.zl.console.dto.autocode.webComponent.ResWebComponentDetailDTO;
import com.my.zl.console.service.autocode.IWebComponentService;
import com.my.zl.console.dto.autocode.webComponent.ResWebComponentStateDTO;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * 前端组件
 * @author ZL
 */
@Api(value="前端组件",tags ="前端组件")
@RestController
@RequestMapping("/api/autocode/webComponent")
public class WebComponentController extends BaseController {

    @Autowired
    private IWebComponentService webComponentService;
    
    /**
     * 查询
     */
    @ApiOperation(value="前端组件-查询")
    @RequestMapping(value="/list", method = RequestMethod.GET)
    public ResDTO<ResWebComponentQueryDTO> listWebComponent(ReqWebComponentQueryDTO reqInfo,PageQueryDTO page) throws Exception{
        ResWebComponentQueryDTO data = webComponentService.queryWebComponentList(reqInfo,page);
        return successDATA(data);
    }
    
   /**
     * 详情
     */
    @ApiOperation(value="前端组件-详情")
    @RequestMapping(value="/detail", method = RequestMethod.GET)
    public ResDTO<ResWebComponentDetailDTO> detailWebComponent(ReqWebComponentDetailDTO reqInfo) throws Exception{
        ResWebComponentDetailDTO data = webComponentService.queryWebComponentDetail(reqInfo);
        return successDATA(data);
    }
    
    /**
     * 新增
     */
    @ApiOperation(value="前端组件-新增")
    @RequestMapping(value="/add", method = RequestMethod.POST)
    public ResDTO<ResWebComponentAddDTO> addWebComponent(@RequestBody ReqDTO<ReqWebComponentAddDTO> reqInfo) throws Exception{
        ResWebComponentAddDTO data = webComponentService.insertWebComponentInfo(reqInfo);
        return successDATA(data);
    }
    
    /**
     * 编辑
     */
    @ApiOperation(value="前端组件-编辑")
    @RequestMapping(value="/edit", method = RequestMethod.POST)
    public ResDTO<ResWebComponentEditDTO> editWebComponent(@RequestBody ReqDTO<ReqWebComponentEditDTO> reqInfo) throws Exception{
        ResWebComponentEditDTO data = webComponentService.updateWebComponentInfo(reqInfo);
        return successDATA(data);
    }
    
    /**
     * 删除
     */
    @ApiOperation(value="前端组件-删除")
    @RequestMapping(value="/del", method = RequestMethod.POST)
    public ResDTO<ResWebComponentDelDTO> delWebComponent(@RequestBody ReqDTO<ReqWebComponentDelDTO> reqInfo) throws Exception{
        ResWebComponentDelDTO data = webComponentService.deleteWebComponentInfo(reqInfo);
        return successDATA(data); 
    }
    
    /**
     * 状态更新
     */
    @ApiOperation(value="前端组件-状态更新")
    @RequestMapping(value="/state", method = RequestMethod.POST)
    public ResDTO<ResWebComponentStateDTO> stateWebComponent(@RequestBody ReqDTO<ReqWebComponentStateDTO> reqInfo) throws Exception{
        ResWebComponentStateDTO data = webComponentService.updateWebComponentState(reqInfo);
        return successDATA(data); 
    }
    
    
}